<template>
  <div class="shop">
    <Header></Header>
    <div class="shopList">
      <!-- <van-tabs v-model="active"> -->
      <van-tabs v-model="active" @click-tab="changId($event)">
        <van-tab v-for="(nav,index) in categoryStore.categoryL2List" :title="nav.name" :key="nav.id">
          <div class="goods" v-for="shop in categoryStore.categoryL2List" :title="shop.name">
            <div class="list" v-for="items in categoryStore.categoryItems.itemList" @click="iphone(items.id)">
              <img class="listImg" :src="items.listPicUrl" alt="">
              <div class="name">
                <img src="https://yanxuan.nosdn.127.net/static-union/1665999514e1f775.png" alt="">
                {{items.name}}
              </div>
              <div class="price">
                <div class="p1">
                  <span>￥</span>
                  <span>{{items.retailPrice}}</span>
                  <span>￥</span>
                  <span>{{items.sortOriginPrice}}</span>
                </div>
              </div>
              <div class="content">
                <div class="left">{{items.finalPriceInfoVO.banner&&items.finalPriceInfoVO.banner.title}}</div>

              </div>
              <div class="text">{{items.finalPriceInfoVO.banner&&items.finalPriceInfoVO.banner.content}}</div>
            </div>

          </div>

        </van-tab>
        <!-- <van-tab title="标签 2">内容 2</van-tab>
        <van-tab title="标签 3">内容 3</van-tab>
        <van-tab title="标签 4">内容 4</van-tab> -->
      </van-tabs>
    </div>
    <div class="shopMain"></div>
  </div>
</template>

<script lang="ts">
import { onMounted, ref } from 'vue';
import { getshopList, reqGetPhone } from '@/api/category';
import { useCategoryStore } from '@/store/category';
import { useRouter } from 'vue-router';
import Header from '../components/Header/index.vue';

export default {
  name: 'Goods',
  components: {
    Header
  }
};
</script>
<script lang="ts" setup>
const categoryStore: any = useCategoryStore();
const active = ref(0);
const router = useRouter();
const id1 = router.currentRoute.value.query.id1
const id2 =router.currentRoute.value.query.id2
onMounted(() => {
  categoryStore.shopList(id1,id2)
});
const changId = (e: any) => {
  const Id = categoryStore.categoryL2List.find((item: { name: any }) => item.name === e.title)?.id;
  categoryStore.shopList(Id, categoryStore.id);

  // console.log('eeeeee', e);
  // console.log('idiiddi', Id);
};
const iphone = (id: number) => {
  router.push('/iphone');
  const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  const random = arr[Math.floor(Math.random() * arr.length)];
  categoryStore.getPhone(random);
};
</script>

<style lang="less" scoped>
.shopList {
  width: 100vw;
  height: 400px;
}
.goods {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  .list {
    width: 45vw;
    display: flex;
    flex-direction: column;
    margin-top: 10px;
    .listImg {
      width: 172px;
      height: 172px;
    }
    .name {
      width: 172px;
      font-size: 12px;
      margin: 8px 0 0;
      img {
        width: 44px;
        height: 17px;
      }
    }
    .price {
      height: 20px;
      line-height: 30px;
      display: flex;
      margin-bottom: 8px;
      irst-child {
        font-size: 12px;
        color: #fa1e32;
      }
      :nth-child(2) {
        font-size: 20px;
        color: #fa1e32;
      }
      :nth-child(3) {
        font-size: 12px;
        color: #999999;
        text-decoration: line-through;
      }
      :nth-child(4) {
        font-size: 12px;
        color: #999999;
        text-decoration: line-through;
      }
    }
    .content {
      width: 172px;
      background-color: #ffe9eb;
      border-radius: 20px;
      .left {
        width: 60px;
        font-size: 12px;
        padding: 2px;
        background-color: #fa1e32;
        border-radius: 12px;
        color: #ffe9eb;
        font-weight: 700;
      }
    }
    .text {
      font-size: 12px;
      color: #fa1e32;
      font-weight: 700;
      text-align: left;
      margin: 0 0 0 4px;
      align-self: flex-start;
    }
  }
}
</style>



